import os
from dotenv import load_dotenv

# 加载环境变量
load_dotenv()

class app_Config:
    SECRET_KEY = os.getenv('SECRET_KEY', 'your-secret-key-here')
    SQLALCHEMY_DATABASE_URI = os.getenv('DATABASE_URL', 'sqlite:///auth.db')
    SQLALCHEMY_TRACK_MODIFICATIONS = False
    SECURITY_PASSWORD_SALT = os.getenv('PASSWORD_SALT', 'your-password-salt')
    
    # 日志配置
    LOG_FILE = 'logs/app.log'
    LOG_LEVEL = 'INFO'
    
    # 安全配置
    MAX_LOGIN_ATTEMPTS = 5
    LOCKOUT_TIME = 300  # 5分钟

    # 验证码过期时间
    CAPTCHA_EXPIRE_TIME = 300

class ProductionConfig(app_Config):
    LOG_LEVEL = 'WARNING'

class DevelopmentConfig(app_Config):
    LOG_LEVEL = 'DEBUG'

class TestingConfig(app_Config):
    TESTING = True
    SQLALCHEMY_DATABASE_URI = 'sqlite:///:memory:'

class SmtpServerConfig(app_Config):
    SMTP_SERVER = os.getenv('SMTP_SERVER', 'your-smtp-server')
    SMTP_USER = os.getenv('SMTP_USER', 'your-smtp-user')
    SMTP_PASSWORD = os.getenv('SMTP_PASSWORD', 'your-smtp-password')    
    
    # 邮件重发时间
    LOCKOUT_TIME = 300
    # 邮件过期时间
    RESET_CODE_EXPIRE_TIME = 3600